package hai.wom.org.qyer_destination.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import hai.wom.org.qyer_destination.R;
import hai.wom.org.qyer_destination.bean.HotCity;

/**
 * Created by Administrator on 2017/1/12 0012.
 */

public class MyAdapter_Hot extends BaseAdapter {
   private List<HotCity.DataEntity> list;
   private Context context;

    public MyAdapter_Hot(List<HotCity.DataEntity> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
       ViewHolder holder;
        if (convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_hot_fg,parent,false);
            holder=new ViewHolder();
            holder.tv= (TextView) convertView.findViewById(R.id.tv_item_hot);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
        HotCity.DataEntity dataEntity=list.get(position);
        holder.tv.setText(dataEntity.getName());
        return convertView;
    }
    class ViewHolder{
        TextView tv;
    }
}
